#include <stdio.h>
#include <stdlib.h>

int positive(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main()
{
	int N = 0, i = 0, j = 0;
	long int p = 0;
	int input[10000] = {0};
	int output = 0;

	scanf("%d %d", &N, &p);
	for(i = 0; i < N; i++){
		scanf("%d", &input[i]);	
	}

	//从大到小排序
	qsort(input, N, sizeof(int), positive);
	//纪录数列个数
	for(i = 0; i < N; i++){
		for(j = N - 1; j > i; j--){
			if( j <= i * p){
				if(j - i + 1 > output){
					output = j - i + 1;
				}
			}
		}
	}
	printf("%d\n", output);
	return 0;
}
